<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/17 0017
 * Time: 下午 1:54
 */
namespace app\auth\controller;
use app\common\api\AApi;
use app\common\api\auth\IAuth;
use app\common\api\auth\IRole;


class Api extends AApi implements IRole,IAuth {
    /**
     * 初始化配置
     * @param array $config
     */
    public function __construct(array $config = []){
        parent::__construct();
    }

    /**
     * 用户对象
     */
    static public $obj_Role;
    static public $obj_Auth;

    /**
     * 单列模式实例化对象
     */
    static function Role_getInstance()
    {
        if (empty(self::$obj_Role)) {
            self::$obj_Role = new Role(self::$post_data);
        }
        return self::$obj_Role;
    }
    /**
     * 角色列表
     * @return array|string
     */
    public function role_list()
    {
        $obj = self::Role_getInstance();
        $res = $obj ->role_list();
        return create_callback($res);
    }
    /**
     * 添加角色
     * @return array|string
     */
    public function role_add()
    {
        $obj = self::Role_getInstance();
        $res = $obj ->role_add();
        return create_callback($res);
    }
    /**
     * 修改角色
     * @return array|string
     */
    public function role_update()
    {
        $obj = self::Role_getInstance();
        $res = $obj ->role_update();
        return create_callback($res);
    }
    /**
     * 修改角色
     * @return array|string
     */
    public function user_role_update()
    {
        $obj = self::Role_getInstance();
        $res = $obj ->user_role_update();
        return create_callback($res);
    }

    /**
     * 单列模式实例化对象
     */
    static function Auth_getInstance(){
        if (empty(self::$post_data)){
            self::$obj_Auth = new Auth(self::$post_data);
        }
        return self::$obj_Auth;
    }
    /**
     * 权限列表
     * @return array|string
     */
    public function auth_list()
    {
        $obj = self::Auth_getInstance();
        $res = $obj ->auth_list();
        return create_callback($res);
    }
    /**
     * 添加权限
     * @return array|string
     */
    public function auth_add(){
        $obj = self::Auth_getInstance();
        $res = $obj ->auth_add();
        return create_callback($res);
    }
    /**
     * 修改权限
     * @return array|string
     */
    public function auth_update(){
        $obj = self::Auth_getInstance();
        $res = $obj ->auth_update();
        return create_callback($res);
    }
}